﻿ 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using Sharp.Portal.Mvc.List;
using Sharp.Portal.Other;

namespace Sharp.Portal.Mvc
{
    /// <summary>
    /// 列扩展方法
    /// </summary>
    public static class ColumnItemExtension
    {
        /// <summary>
        /// 列特性
        /// </summary> 
        /// <param name="column"></param>
        /// <param name="feature"></param>
        /// <returns></returns>
        public static ColumnItem Feature(this ColumnItem column, ColumnFeature feature)
        {
            column.Feature |= feature;
            return column;
        }
        /// <summary>
        /// 查询特性
        /// </summary> 
        /// <param name="column"></param>
        /// <param name="feature"></param>
        /// <returns></returns>
        public static ColumnItem QueryFeature(this ColumnItem column, QueryFeature feature)
        {
            column.QueryFeatureOption |= feature;
            return column;
        }
        /// <summary>
        /// 宽度
        /// </summary> 
        /// <param name="column"></param>
        /// <param name="width"></param>
        /// <returns></returns>
        public static ColumnItem Width(this ColumnItem column, int width)
        {
            column.Width = width;
            return column;
        }
        /// <summary>
        /// 格式化字符
        /// </summary>
        /// <param name="column"></param>
        /// <param name="format"></param>
        /// <returns></returns>
        public static ColumnItem ExtFormat(this ColumnItem column, string format)
        {
            column.Format = format;
            return column;
        }
        /// <summary>
        /// 查询默认值
        /// </summary>
        /// <param name="column">查询项</param>
        /// <param name="defaultValue">值</param>
        /// <returns></returns>
        public static ColumnItem QueryDefaultValue(this ColumnItem column, object defaultValue)
        {
            column.QueryDefaultValue = defaultValue;
            return column;
        }
        /// <summary>
        /// 搜索哪个字段
        /// </summary>
        /// <param name="column"></param>
        /// <param name="fieldName"></param>
        /// <returns></returns>
        public static ColumnItem SearchFor(this ColumnItem column, string fieldName)
        {
            column.DataIndex = fieldName;
            return column;
        }
    }
}